clear all

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"
local path1="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\outregs"

capture cd "`path0'Workfiles"
set more off
use completed_data, clear


	* create settler mortality with the African data corrected based on Albouy
	capture drop logmort3
	gen logmort3=logmort2
	replace logmort3=logmort if countrycode=="SGP" | countrycode=="AUS"
	
	gen lnUKdist=log(geo_UK_distw)

		
	*** OLS	
	xi: reg pwt_ln_rgdpwok idv , robust 
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: all") 
	
	*** IV	
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK) , robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV: OECD") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`		
	*			include countries only with stable population
	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`	
			
	*** OLS	
	xi: reg pwt_ln_rgdpwok idv   if share_putterman>0.8 & share_putterman~=., robust 
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: stable 0.8") 
	
	*** IV	
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK)  if share_putterman>0.8 & share_putterman~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV:  stable 0.8") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		

	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`		
	*			include countries only with stable population
	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`	
			
	*** OLS	
	xi: reg pwt_ln_rgdpwok idv   if share_putterman>0.9 & share_putterman~=., robust 
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: stable 0.9") 
	
	*** IV	
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK)  if share_putterman>0.9 & share_putterman~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV:  stable 0.9") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')

	

	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`		
	*			include countries only with stable population
	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`	
			
	*** OLS	
	xi: reg pwt_ln_rgdpwok idv   if share_putterman>0.95 & share_putterman~=., robust 
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: stable 0.95") 
	
	*** IV	
	xi: ivreg2 pwt_ln_rgdpwok (idv = distM_UK)  if share_putterman>0.95 & share_putterman~=., robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\RR_table004.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV:  stable 0.95") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
